<!DOCTYPE html>
<meta charset="UTF-8">
<div style="margin: 10px 0;">
	<a href="javascript:void(0)" data-type="linkbutton" data-define="'width':120" onclick="collapseAll()">关闭所有</a>
	<a href="javascript:void(0)" data-type="linkbutton" data-define="'width':120" onclick="expandAll()">展开所有</a>
	<a href="javascript:void(0)" data-type="linkbutton" data-define="'width':120" onclick="expandTo()">展开并选择</a>
</div>
<table id="tg" data-type="gridtree" title="树形列表事件" style="width: auto; height: 250px"
	data-define="
				iconCls: 'icon-ok',
				rownumbers: true,
				animate: true,
				collapsible: true,
				fitColumns: true,
				method:'get',url: '${rc.contextPath}/assets/ui/jww/demo/testdata/gridtree_data2.json',
				idField: 'id',
				treeField: 'name'
			">
	<thead>
		<tr>
			<th data-define="field:'name',width:180">任务名称</th>
			<th data-define="field:'persons',width:60,align:'right'">责任人</th>
			<th data-define="field:'begin',width:80">开始日期</th>
			<th data-define="field:'end',width:80">结束日期</th>
			<th data-define="field:'progress',width:120,formatter:formatProgress">进程</th>
		</tr>
	</thead>
</table>
<script type="text/javascript">
	function formatProgress(value) {
	    if (value) {
		    var s = '<div style="width:100%;border:1px solid #ccc">' + '<div style="width:' + value
		            + '%;background:#cc0000;color:#fff">' + value + '%' + '</div>'
		    '</div>';
		    return s;
	    } else {
		    return '';
	    }
    }
    function collapseAll() {
	    $('#tg').gridtree('collapseAll');
    }
    function expandAll() {
	    $('#tg').gridtree('expandAll');
    }
    function expandTo() {
	    $('#tg').gridtree('expandTo', 21).gridtree('select', 21);
    }
</script>
